﻿using System;
using System.IO;
using System.Collections.Generic;

namespace Zove.Query {
    public class ZoveQuery {
        public static void Main(string[] args) {
            if (args.Length < 0) {
                Console.WriteLine("Please specify a query file.");
                return;
            }

            QueryManager qm = new QueryManager();
            string content = File.ReadAllText(args[0]);
            string[] queries = content.Split(';');
            foreach (string query in queries) {
                if (string.IsNullOrEmpty(query)) {
                    continue;
                }

                Console.WriteLine(query);
                Query q = qm.CreateQuery(query + ";");

                List<QueryResult> results = q.Run();
                foreach (QueryResult result in results) {
                    Console.WriteLine("{0} = {1}", result.Item, result.Value);
                }
            }
        }
    }
}
